package com.zfj.service.impl;

import com.zfj.service.IMessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author zfj
 * @date 2022/5/15 -14:41
 */
@EnableBinding(Source.class) //定义消息推送管道
public class IMessageProviderImpl implements IMessageProvider {

	@Resource
	private MessageChannel output; //消息通道
	@Override
	public String send() {
		String serial = UUID.randomUUID().toString();
		output.send(MessageBuilder.withPayload(serial).build());
		System.out.println("***serial"+serial);
		return null;
	}
}
